package tt.dz.appserver.dao.ext;

import java.util.List;

import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.cache.annotation.Caching;
import org.springframework.stereotype.Repository;

import tt.dz.appserver.dao.base.BasisDao;
import tt.dz.appserver.entity.model.StationComment;
import tt.dz.appserver.entity.model.pub.Shares;
import tt.dz.appserver.entity.model.pub.station.StationCommentReply;
import tt.dz.appserver.util.Constants;

/**
 * 分享评论dao
 * @author Administrator
 *
 */
@Repository
public class StationCommentReplyDao extends BasisDao<StationCommentReply>{

	
	/**
	 * 查询评论的回复
	 * @param replyId
	 * @return
	 */
	@Cacheable(value="stationCommentReplys",key="'commentId'+#commentId")
	public List<StationCommentReply> findStationCommentReplyByCommentId(String commentId){
		
		StationCommentReply reply = new StationCommentReply();
		reply.setValid_flag(1);
		reply.setComment_id(commentId);	
		return super.findExample(reply, null, null, "create_time", 0);
	}
	
	
	@Cacheable(value="stationCommentReplys",key="'commentId'+#commentId+'pageNo'+#pageNo")
	public List<StationCommentReply> getStationCommentByCommentId(String commentId, Integer pageNo){
		
		StationCommentReply stationCommentReply = new StationCommentReply();
		stationCommentReply.setComment_id(commentId);
		return super.findExample(stationCommentReply, pageNo, Constants.PAGE_SIZE, "create_time", 0);
	}
	
	/**
	 * 新增分享评论
	 */
	@CacheEvict(value="stationCommentReplys",key="#stationCommentReply.comment_id")
	@Override
	public int save(StationCommentReply stationCommentReply) {
		return super.save(stationCommentReply);
	}
	/**
	 * 逻辑删除
	 */
	@CacheEvict(value="stationCommentReplys",allEntries=true)
	public int LogicDelete(StationCommentReply obj) {
		return super.LogicDelete(obj);
	}
}
